package android.slc.module.component.player.base;


import android.slc.module.component.player.constant.MediaPlayerStatus;
import android.slc.module.component.player.source.IMediaSource;

/**
 * @author slc
 * @date 2022/05/18 上午 10:39
 */
public interface IMedia {
    int OPERATE_RESULT_DONE = 0;
    int OPERATE_RESULT_SUCCESS = 1;
    int OPERATE_RESULT_FAIL = 3;

    IMediaSource getMediaSource();

    void setMediaSource(IMediaSource mediaSource);

    boolean isPlaying();

    MediaPlayerStatus getMediaStatus();

    void setMediaPlayerEventListener(MediaPlayerEventListener mediaPlayerEventListener);

    CacheHandler getCacheAdapter();

    void setCacheAdapter(CacheHandler cacheHandler) throws RuntimeException;

    int start();

    int pause();

    int stop();

    int autoPlayStatus();

    void release();

    long getPlayerProgress();

    long getDuration();


    interface MediaPlayerEventListener {
        void onPrepare();

        void onStart();

        void onPause();

        void onStop();

        void onError(int errorCode, String errorMsg);

        void onComplete();

        void onProgressChange(long progress);
    }


    interface CacheHandler {

        //------------------缓存配置start---------------------//
        IMedia getMedia();

        void setMedia(IMedia media);

        String getCachePath();

        void setCachePath(String cachePath);

        void startCache();

        default void pauseCache() {
            stopCache();
        }

        void stopCache();

        int getCacheStatus();

        boolean isCaching();

        /**
         * 创建缓存文件路径
         *
         * @return
         */
        String createCacheFilePath();

        String createCacheFilePath(boolean apply);

        /**
         * 创建缓存文件路径
         *
         * @param apply       应用到this
         * @param newInstance true替换，反之生成新的
         * @return
         */
        String createCacheFilePath(boolean apply, boolean newInstance);

        String getCurrentCacheFilePath();

        void setCurrentCacheFilePath(String currentCacheFilePath);

        //截图

        boolean isSnapshots();

        void setAutoSnapshots(boolean snapshots);

        boolean isAutoSnapshots();

        void snapshots();
        /**
         * 创建截图文件路径
         *
         * @return
         */
        String createSnapshotsFilePath();

        String createSnapshotsFilePath(boolean apply);

        /**
         * 创建截图文件路径
         *
         * @param apply       应用到this
         * @param newInstance true替换，反之生成新的
         * @return
         */
        String createSnapshotsFilePath(boolean apply, boolean newInstance);

        String getCurrentSnapshotsFilePath();

        void setCurrentSnapshotsFilePath(String currentSnapshotsFilePath);
    }
}
